const regtel = /^(13[0-9]|14[57]|15[0123456789]|18[012356789])\d{8}$/;
const regduanxin = /^\d{6}$/
const regpw = /^[a-zA-Z0-9_\.-]{6,16}$/;
const number = document.querySelector("#phonenumber")
const duanxin = document.querySelector("#duanxin")
const password = document.querySelector("#password")
const password1 = document.querySelector("#password1")
function regexp(number, reg, type) {
    number.onblur = function () {
        const str = this.value.trim();
        if (str == '') {
            this.parentElement.nextElementSibling.setAttribute('style', 'color: red;')
            this.parentElement.nextElementSibling.innerText = `输尼玛，没有输入${type}！`
        } else if (reg.test(str)) {
            this.parentElement.nextElementSibling.setAttribute('style', 'color: green;')
            this.parentElement.nextElementSibling.innerText = `${type}输入正确`
        } else {
            this.parentElement.nextElementSibling.setAttribute('style', 'color: red;')
            this.parentElement.nextElementSibling.innerText = `${type}输入错误`
        }
    }
}
regexp(number, regtel, "手机号码格式");
regexp(duanxin, regduanxin, "短信验证码");
regexp(password, regpw, "密码格式");
password1.onblur = function () {
    if (password1.value == password.value) {
        this.parentElement.nextElementSibling.setAttribute('style', 'color: green;')
        this.parentElement.nextElementSibling.innerText = `密码输入一致`
    } else {
        this.parentElement.nextElementSibling.setAttribute('style', 'color: red;')
        this.parentElement.nextElementSibling.innerText = `两次密码输入不一致`
    }
}

